home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 6
/
FM Towns Free Software Collection 6.iso
/
t_os
/
igo
/
src
/
gadget.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-07-08
|
6KB
|
301 lines
#define DEBUG 0
/*
TOWNS囲碁棋譜記録プログラム gadget.c
1992/05/05 久保田俊也
*/
#include <stdio.h>
#include <time.h>
#include "igo.h"
#include "ban19.h"
#define MAX_ABLE_NUMBER 400 /* 打つことができる盤の最大位置 */
int uchiage(int ichi, char ban[])
{
int i, j;
int k = 0;
char g_no[MAX_ABLE_NUMBER];
for(i=0;i<MAX_ABLE_NUMBER;i++){
g_no[i] = 0;
}
for(i=21;i<MAX_ABLE_NUMBER;i++){
if(ban[i] == BLACK || ban[i] == WHITE){
if(ban[i] == ban[i+UP]){
g_no[i] = g_no[i+UP];
if(ban[i] == ban[i+LEFT]){
for(j=22;j<i;j++){
if(g_no[j] == g_no[i+LEFT]){
g_no[j] = g_no[i];
}
}
}
}else{
if(ban[i] == ban[i+LEFT]){
g_no[i] = g_no[i+LEFT];
}else{
g_no[i] = ++k;
}
}
}
}
if(ban[ichi] != ban[ichi+UP] && ban[ichi+UP] !=WALL
&& ban[ichi+UP] !=BLANK ){
if(damesu(ichi+UP, g_no, ban) == 0){
for(i=21;i<MAX_ABLE_NUMBER;i++){
if(g_no[i] == g_no[ichi+UP]){
ban[i] = BLANK;
}
}
}
}
if(ban[ichi] != ban[ichi+LEFT] && ban[ichi+LEFT] !=WALL
&& ban[ichi+LEFT] !=BLANK ){
if(damesu(ichi+LEFT, g_no, ban) == 0){
for(i=21;i<MAX_ABLE_NUMBER;i++){
if(g_no[i] == g_no[ichi+LEFT]){
ban[i] = BLANK;
}
}
}
}
if(ban[ichi] != ban[ichi+RIGHT] && ban[ichi+RIGHT] !=WALL
&& ban[ichi+RIGHT] !=BLANK ){
if(damesu(ichi+RIGHT, g_no, ban) == 0){
for(i=21;i<MAX_ABLE_NUMBER;i++){
if(g_no[i] == g_no[ichi+RIGHT]){
ban[i] = BLANK;
}
}
}
}
if(ban[ichi] != ban[ichi+DOWN] && ban[ichi+DOWN] !=WALL
&& ban[ichi+DOWN] !=BLANK ){
if(damesu(ichi+DOWN, g_no, ban) == 0){
for(i=21;i<MAX_ABLE_NUMBER;i++){
if(g_no[i] == g_no[ichi+DOWN]){
ban[i] = BLANK;
}
}
}
}
return 0;
}
damesu(ichi, g_no, ban) /* 現在は0とそれ以外しか区別していない */
int ichi;
char g_no[];
char ban[];
{
int i;
for(i=21;i<MAX_ABLE_NUMBER;i++){
if(g_no[i] == g_no[ichi]){
if(ban[i+UP] == BLANK || ban[i+LEFT] == BLANK
|| ban[i+RIGHT] == BLANK || ban[i+DOWN] == BLANK ){
return(1);
}
}
}
return(0);
}
int ban_init(size, ban)
int size;
char ban[];
{
int i, j;
for(i=0;i< (size+1)*(size+2)+1;i++){
ban[i] = WALL;
}
for(i=1;i<20;i++){
for(j=1;j<20;j++){
ban[j + i*20] = BLANK;
}
}
return 0;
}
handy_dispset(handy, ban)
int handy;
char ban[BANSIZE2];
{
switch(handy){
case '2' + 0:
ban[96] = BLACK;
ban[324] = BLACK;
break;
case '2' + 1:
ban[96] = BLACK;
ban[324] = BLACK;
ban[336] = BLACK;
break;
case '2' + 2:
ban[84] = BLACK;
ban[96] = BLACK;
ban[324] = BLACK;
ban[336] = BLACK;
break;
case '2' + 3:
ban[84] = BLACK;
ban[96] = BLACK;
ban[210] = BLACK;
ban[324] = BLACK;
ban[336] = BLACK;
break;
case '2' + 4:
ban[84] = BLACK;
ban[96] = BLACK;
ban[204] = BLACK;
ban[216] = BLACK;
ban[324] = BLACK;
ban[336] = BLACK;
break;
case '2' + 5:
ban[84] = BLACK;
ban[96] = BLACK;
ban[204] = BLACK;
ban[210] = BLACK;
ban[216] = BLACK;
ban[324] = BLACK;
ban[336] = BLACK;
break;
case '2' + 6:
ban[84] = BLACK;
ban[90] = BLACK;
ban[96] = BLACK;
ban[204] = BLACK;
ban[216] = BLACK;
ban[324] = BLACK;
ban[330] = BLACK;
ban[336] = BLACK;
break;
case '2' + 7:
ban[84] = BLACK;
ban[90] = BLACK;
ban[96] = BLACK;
ban[204] = BLACK;
ban[210] = BLACK;
ban[216] = BLACK;
ban[324] = BLACK;
ban[330] = BLACK;
ban[336] = BLACK;
break;
case '2' + 8:
ban[84] = BLACK;
ban[96] = BLACK;
ban[324] = BLACK;
break;
default:
break;
}
return 0;
}
handy_prinset(handy, ban)
int handy;
int ban[BANSIZE2];
{
switch(handy){
case '2' + 0:
ban[96] = HANDY_STONE;
ban[324] = HANDY_STONE;
break;
case '2' + 1:
ban[96] = HANDY_STONE;
ban[324] = HANDY_STONE;
ban[336] = HANDY_STONE;
break;
case '2' + 2:
ban[84] = HANDY_STONE;
ban[96] = HANDY_STONE;
ban[324] = HANDY_STONE;
ban[336] = HANDY_STONE;
break;
case '2' + 3:
ban[84] = HANDY_STONE;
ban[96] = HANDY_STONE;
ban[210] = HANDY_STONE;
ban[324] = HANDY_STONE;
ban[336] = HANDY_STONE;
break;
case '2' + 4:
ban[84] = HANDY_STONE;
ban[96] = HANDY_STONE;
ban[204] = HANDY_STONE;
ban[216] = HANDY_STONE;
ban[324] = HANDY_STONE;
ban[336] = HANDY_STONE;
break;
case '2' + 5:
ban[84] = HANDY_STONE;
ban[96] = HANDY_STONE;
ban[204] = HANDY_STONE;
ban[210] = HANDY_STONE;
ban[216] = HANDY_STONE;
ban[324] = HANDY_STONE;
ban[336] = HANDY_STONE;
break;
case '2' + 6:
ban[84] = HANDY_STONE;
ban[90] = HANDY_STONE;
ban[96] = HANDY_STONE;
ban[204] = HANDY_STONE;
ban[216] = HANDY_STONE;
ban[324] = HANDY_STONE;
ban[330] = HANDY_STONE;
ban[336] = HANDY_STONE;
break;
case '2' + 7:
ban[84] = HANDY_STONE;
ban[90] = HANDY_STONE;
ban[96] = HANDY_STONE;
ban[204] = HANDY_STONE;
ban[210] = HANDY_STONE;
ban[216] = HANDY_STONE;
ban[324] = HANDY_STONE;
ban[330] = HANDY_STONE;
ban[336] = HANDY_STONE;
break;
case '2' + 8:
ban[84] = HANDY_STONE;
ban[96] = HANDY_STONE;
ban[324] = HANDY_STONE;
break;
default:
break;
}
return 0;
}